const User = require("../../model/user");

module.exports = {
  Query: {
    async getUserInfo(root, { id }, ctx) {
      try {
        let user = await User.findByPk(id);
        return {
          code: 1,
          data: user
        };
      } catch (error) {
        console.log(error);
        throw error;
      }
    }
  },

  Mutation: {
    async register(root, { user }, ctx) {
      console.log(user);
      try {
        let res = await User.create(user);
        return {
          code: 1,
          msg: "ok",
          data: res
        };
      } catch (error) {
        console.log(error);
        throw error;
      }
    }
  }
};
